<?php

function custom_css_styles() {
		echo '<link type="text/css" href="$stylesheet_uri" media="all" />';
	// pretend there is a button style
	echo '<input name="accept" type="submit" value="Accept" />';
}
class themes {
	public function theme_creation($stylesheet_uri) {
		($stylesheet_uri == "stylesheet1.css") ? include_once($stylesheet_uri) : exit;
		($stylesheet_uri == "stylesheet2.css") ? include_once($stylesheet_uri) : exit;
		echo "hello world";
	}
}

//@$theme = new themes();
//@$theme->theme_creation("stylesheet1.css");

class pages {
	public function startpage() {
		if ($_SERVER["PHP_SELF"] == "/lib/friend-function-s1.php") {
			echo "hello";
			 ?>
			<!---- this is an example page ---->
				<br>
				<form method='GET' action='" . $_SERVER['PHP_SELF'] . "?action=1'>
				<input name="accept" type="submit" value="Accept" />

				<form method='GET' action='" . $_SERVER['PHP_SELF'] . "?action=0'>
				<input name="deny" type="submit" value="Deny" />
				</form>
				<br>
			<!---- this is an example page ---->
		<?php
		}
		elseif ($filename != "friend-function-s1.php") {
					// tie in the theming system for a more beautified display
				echo "Sorry but the page requested does not exsist";
		}
	}
	public function mysql_extended($dbhost, $dbuser, $dbpass, $dbname) {
		// making the mysql connection dynamically editable
		$mysql_connect 	=	mysql_connect($dbhost, $dbuser, $dbpass)or die("Could not connect: " . mysql_error());
		$mysql_select_db =	mysql_select_db($dbname) or die(mysql_error());
		echo "success: ";
	}
}

//$pages = new Pages();
//$pages->mysql_extended("localhost", "root", "", "druvla_core");
//$pages->startpage();

function friends_lister() {
		mysql_connect("localhost", "root", "")or die("Could not connect: " . mysql_error());
		mysql_select_db("druvla_public") or die(mysql_error());
	if ($_GET['action'] == "0") {
		mysql_query("INSERT IGNORE INTO requests (RequestSentByID, RequestRecipientID, RequestStatus, AddedMessage, FriendType)
			VALUES(1, '$userid_generator', 'Accepted', 'Welcome to Druvla', 'full')")or die(mysql_error());
		mysql_query("INSERT INTO users (UserID, username, password, first_name, last_name, email_address)
			VALUES('$userid_generator', '$username', '$password', '$first_name', '$last_name', '$email')")or die(mysql_error());
	}
	if ($_GET['action'] == "1") {
		mysql_query("INSERT IGNORE INTO requests (RequestSentByID, RequestRecipientID, RequestStatus, AddedMessage, FriendType)
			VALUES(1, '$userid_generator', 'Denied', 'Welcome to Druvla', 'full')")or die(mysql_error());
		mysql_query("INSERT INTO users (UserID, username, password, first_name, last_name, email_address)
			VALUES('$userid_generator', '$username', '$password', '$first_name', '$last_name', '$email')")or die(mysql_error());
	}
include("processing/global-settings.php");
$userid = $_SESSION['userid'];
mysql_connect($dbhost, $dbuser, $dbpass)or die("Could Not Connect: " . mysql_error());
mysql_select_db($dbname) or die(mysql_error());
$results = mysql_query("SELECT requests.RequestRecipientID, requests.StatusType, requests.AddedMessage, requests.FriendType, requests.RequestSentByID, requests.id, users.username, users.first_name, users.last_name, users.email, users.user_pid, users.id FROM requests, users WHERE RequestRecipientID = '$userid' AND users.user_pid = requests.RequestRecipientID");
while($row = mysql_fetch_array($results)) {
	if ($row['StatusType'] == "Accepted") {
		echo $row['first_name'] . " has accepted your friend request.";
	} elseif ($row['StatusType'] == "Denied") {
		echo $row['RequestSentByID'] . " has denied your request.";
	} elseif ($row['StatusType'] == "Pending") {
	echo "<br>";
	echo $row['id'] . ": ";
	echo $row['RequestRecipientID'];
	echo "<form method='GET' action='protected/process-friend-request-action.php?" . $row['id'] . "'>";
	echo '<input name="accepted" type="submit" value="Accept" />';
	echo '<input name="denied" type="submit" value="Deny" />';
	echo '<input type="hidden" name="id" value="' . $row["id"] . '" />';
	echo '</form>';
	echo "<br>";
	echo $row['first_name'];
	}
}
}

include("full-user-listing.php");
full_user_listing();
?>